<script type="text/javascript" >
    sttheme.load_tooltip();
    sttheme.on_submitform('#settingForm', function(data) {
        sttheme.loadPage('game', '', '<?php _e("Successful", 'sttheme'); ?>');
    });

    sttheme.loadUploadButton();
    sttheme.loadRemoveButton();
</script>

<div class="w100p bgl">
    <div class="w100p bgr p5b">
        <form class="stform" id="settingForm" action="<?php echo admin_url('/admin.php?page=' . $config['theme_name'] . '&action=' . $current_action) ?>" method="post" >
           <fieldset>
            <legend>General settings</legend>
            <ul>
                <li>
                    <label><?php _e('Name title', $config['plugin_name']) ?>:</label>
                    <div class="required">
                        <input value="<?php echo $result->title ?>" class="required" name="data[title]" type="text" tabindex="3" />
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label><?php _e('Name image', $config['sttheme']); ?>:</label>
                    <div class="required">
                        <?php
                        $class_hide = "hide";
                        if (!empty($result->name)) {
                            $stplugin_picture_url = $result->name;
                            $class_hide = "";
                        }
                        ?>
                        <input value="<?php echo $stplugin_picture_url ?>"  name="data[name]" id="id_stplugin_picture" type="hidden"/>
                        <div class="upload_button_div">
                            <span id="stplugin_picture" class="button image_upload_button">Upload photo</span>
                            <span pictureID="stplugin_picture" id="reset_stplugin_picture" class="button image_reset_button <?php echo $class_hide ?>">Remove</span>
                        </div>
                        <?php
                        if (!empty($result->name)) {
                            ?>
                            <img alt="" src="<?php echo $stplugin_picture_url ?>" id="image_stplugin_picture" class="hide preview" style="display: inline;"/>
                        <?php } ?>
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label>Current Game</label>
                    <div class="required">
                        <input <?php echo $result->is_top == 1 ? 'checked' : '' ?>  value="1" class="required" name="data[is_top]"  type="radio" tabindex="5" />
                        <label><?php _e('Yes', $config['plugin_name']) ?></label>
                        <input <?php echo $result->is_top == 0 ? 'checked' : '' ?> value="0" class="required" name="data[is_top]"  type="radio" tabindex="6" />
                        <label><?php _e('No', $config['plugin_name']) ?></label>
                    </div>
                    <br clear="both" />
                </li>

                <li>
                    <label><?php _e('Order', $config['plugin_name']) ?>:</label>
                    <div >
                        <input value="<?php echo $result->sort_order ?>"  name="data[sort_order]" type="text" tabindex="3" />
                    </div>
                    <br clear="both" />
                </li>
                
            </ul>
           </fieldset>
            
            <fieldset>
            <legend>APP settings</legend>
            <ul>
                <li>
                    <label><?php _e('APP URL', $config['plugin_name']) ?>:</label>
                    <div >
                        <input value="<?php echo $result->app_url ?>"  name="data[app_url]" type="text" tabindex="3" />
                    </div>
                    <br clear="both" />
                </li>
               <li>
                    <label><?php _e('Iframe Height', $config['plugin_name']) ?>:</label>
                    <div>
                        <input value="<?php echo $result->iframe_height ?>"  name="data[iframe_height]" type="text" tabindex="3" />
                    </div>
                    <br clear="both" />
                </li>
                 <li>
                    <label><?php _e('App cover pic', $config['sttheme']); ?>:</label>
                    <div >
                        <?php
                        $class_hide = "hide";
                        if (!empty($result->banner)) {
                            $stplugin_picture_url = $result->banner;
                            $class_hide = "";
                        }
                        ?>
                        <input value="<?php echo $stplugin_picture_url ?>"  name="data[banner]" id="id_stplugin_picture" type="hidden"/>
                        <div class="upload_button_div">
                            <span id="stplugin_picture_banner" class="button image_upload_button">Upload photo</span>
                            <span pictureID="stplugin_picture_banner" id="reset_stplugin_picture_banner" class="button image_reset_button <?php echo $class_hide ?>">Remove</span>
                        </div>
                        <?php
                        if (!empty($result->banner)) {
                            ?>
                            <img alt="" src="<?php echo $stplugin_picture_url ?>" id="image_stplugin_picture_banner" class="hide preview" style="display: inline;"/>
                        <?php } ?>
                    </div>
                    <br clear="both" />
                </li>
            </ul>
           </fieldset>
            
            <fieldset>
            <legend>Thể lệ</legend>
            <ul>
                <li>
                    <label><?php _e('Thể lệ (thumbnail)', $config['sttheme']); ?>:</label>
                    <div class="required">
                        <?php
                        $class_hide = "hide";
                        if (!empty($result->thele_image)) {
                            $stplugin_picture_url = $result->thele_image;
                            $class_hide = "";
                        }
                        ?>
                        <input value="<?php echo $stplugin_picture_url ?>"  name="data[thele_image]" id="id_stplugin_picture" type="hidden"/>
                        <div class="upload_button_div">
                            <span id="stplugin_picture_thele" class="button image_upload_button">Upload photo</span>
                            <span pictureID="stplugin_picture_thele" id="reset_stplugin_picture_thele" class="button image_reset_button <?php echo $class_hide ?>">Remove</span>
                        </div>
                        <?php
                        if (!empty($result->thele_image)) {
                            ?>
                            <img alt="" src="<?php echo $stplugin_picture_url ?>" id="image_stplugin_picture_thele" class="hide preview" style="display: inline;"/>
                        <?php } ?>
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label>Link type </label>
                    <div class="required">
                        <input <?php echo $result->thele_type == 'internal' ? 'checked' : '' ?>  value="internal" class="required" name="data[thele_type]" id="radio1" type="radio" tabindex="5" />
                        <label><?php _e('Internal page', $config['plugin_name']) ?></label>
                        <input <?php echo $result->thele_type == 'external' ? 'checked' : '' ?>  value="external" class="required" name="data[thele_type]" id="radio11" type="radio" tabindex="6" />
                        <label><?php _e('External link', $config['plugin_name']) ?></label>
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label><?php _e('External link', $config['theme_name']) ?>:</label>
                    <div>
                        <input value="<?php echo $result->thele_external ?>" class="" name="data[thele_external]"  type="text"/>
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label><?php _e('Internal page', $config['theme_name']) ?>:</label>
                    <div>
                        <select name="data[thele_internal]"  class="widefat">
                            <?php
                            $page_ids = get_all_page_ids();
                            foreach ($page_ids as $row) {
                                $page = get_page($row);
                                ?>
                                <option value="<?php echo $row ?>" <?php echo $result->thele_internal == $row ? 'selected' : '' ?>><?php echo $page->post_name; ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </li>
            </ul>
            </fieldset>
            <fieldset>
                <legend>Kết quả </legend>
                <ul>
                <li>
                    <label><?php _e('Kết quả (thumbnail)', $config['sttheme']); ?>:</label>
                    <div class="required">
                        <?php
                        $class_hide = "hide";
                        if (!empty($result->ketqua_image)) {
                            $stplugin_picture_url = $result->ketqua_image;
                            $class_hide = "";
                        }
                        ?>
                        <input value="<?php echo $stplugin_picture_url ?>"  name="data[ketqua_image]" id="id_stplugin_picture" type="hidden"/>
                        <div class="upload_button_div">
                            <span id="stplugin_picture_ketqua" class="button image_upload_button">Upload photo</span>
                            <span pictureID="stplugin_picture_ketqua" id="reset_stplugin_picture_ketqua" class="button image_reset_button <?php echo $class_hide ?>">Remove</span>
                        </div>
                        <?php
                        if (!empty($result->ketqua_image)) {
                            ?>
                            <img alt="" src="<?php echo $stplugin_picture_url ?>" id="image_stplugin_picture_ketqua" class="hide preview" style="display: inline;"/>
                        <?php } ?>
                    </div>
                    <br clear="both" />
                </li>
               <li>
                    <label>Link type </label>
                    <div class="required">
                        <input <?php echo $result->ketqua_type == 'internal' ? 'checked' : '' ?>  value="internal" class="required" name="data[ketqua_type]" id="radio1" type="radio" tabindex="5" />
                        <label><?php _e('Internal page', $config['plugin_name']) ?></label>
                        <input <?php echo $result->ketqua_type == 'external' ? 'checked' : '' ?>  value="external" class="required" name="data[ketqua_type]" id="radio11" type="radio" tabindex="6" />
                        <label><?php _e('External link', $config['plugin_name']) ?></label>
                    </div>
                    <br clear="both" />
                </li>
                 <li>
                    <label><?php _e('External link', $config['theme_name']) ?>:</label>
                    <div>
                        <input value="<?php echo $result->ketqua_external ?>" class="" name="data[ketqua_external]"  type="text"/>
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label><?php _e('Internal page', $config['theme_name']) ?>:</label>
                    <div>
                        <select name="data[ketqua_internal]"  class="widefat">
                            <?php
                            $page_ids = get_all_page_ids();
                            foreach ($page_ids as $row) {
                                $page = get_page($row);
                                ?>
                                <option value="<?php echo $row ?>" <?php echo $result->ketqua_internal == $row ? 'selected' : '' ?>><?php echo $page->post_name; ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </li>
                </ul>
            </fieldset>
            <ul>



                <li>
                    <input type="submit" value="Submit"/>
                </li>
                <input value="<?php echo $result->id ?>" class="" name="data[id]"  type="hidden"/>


            </ul>
        </form>
    </div>
</div>